from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import os.path
import glob
import time

def convertjpg(jpgfile,outdir,width=64,height=64):
    img=Image.open(jpgfile)
    #new_img=img.resize((width,height),Image.BILINEAR)
    new_img=img.resize((width,height),Image.BICUBIC)   
    new_img.save(os.path.join(outdir,os.path.basename(jpgfile)), quality=95, subsampling=0)

print("开始处理：")
start = time.time()

for jpgfile in glob.glob("../23class_all_20200615_ori_most_before_resize/*.jpg"):
    convertjpg(jpgfile,"./all_0")
    
end = time.time()
print("处理完成，resize照片耗时: %s分" % ((end - start) / 60))
